#include "absInt.h"
#include "String.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include "CPolygon.h"
#include "multipleInheritance.h"

using namespace std;
extern bool operator==(const String &str1, const String &str2);

int main(){
	
	{
	D d;
	C *cp=&d;
	
	D *dp=dynamic_cast<D *>(cp);
	dp->test();
	//D d;
//	B b;
	//std::cout<<d.geta()<<std::endl;
	//d.amb; ambiguous access since both class B and class C contains amb
	}
	std::cout<<"---------------"<<std::endl;

	CRectangle rec;
	CTriangle tri;
	CPolygon *p1=&rec;
	CPolygon *p2=&tri;
	p1->set_values(4,5);
	p2->set_values(4,5);
	
	
	cout<<p1->area()<<' '<<p2->area()<<' '<<endl;
	//cout<<rec.area()<<endl;
	//cout<<tri.area()<<endl;


	String s1("hello");
	String s2("world");
	cout<<(s1=="hello")<<endl;//invoke member operator== , the compiler treat it as s1.operator==("hello")
	cout<<("world"==s2)<<endl;//invoke operator== defined in namespace,the compiler treat it as operator==(String("world"),s2),this involves implicit type converson from char * to String
	 
	int a[]={0,1,-2,3,4,5,6,-7,8};
	vector<int> vec(a,a+9);
	transform(vec.begin(),vec.end(),vec.begin(),absInt());
	
	for(int i=0;i<vec.size();i++){
		cout<<vec[i]<<endl;
	}
	 
	/*
	s1=s2;//invoke copy assigment operator
	s1="name";//invoke operator=(const char *)
	*/
	/*
	char *p1="hello";
	char *p2="world";
	cout<<strcmp(p1,p2)<<endl;
	*/
	system("pause");
}